package com.training.java.core.collections.car.post15;

import java.util.ArrayList;
import java.util.List;

/**
 * Created multiple objects and adding them to List( generic code)
 * Car1,Car2,Car3 are immutable objects. List accepts duplicate values.
 * 
 * @author Satya
 */
public class CarListDemo {

	public static void main(String[] args) {
		// Created multiple car objects.
		Car car1 = new Car("1234", "Ford", "Focus");
		Car car2 = new Car("2345", "Toyota", "Camry");
		Car car3 = new Car("3456", "BMW", "X5");
		Car car4 = new Car();// mutable object.
		Car car5 = new Car("3456", "BMW", "X5");// duplicate object

		// Creating the List collection

		List<Car> listOfCars = new ArrayList<Car>();

		// Add the objects to the List collection
		listOfCars.add(car1);
		listOfCars.add(car2);
		listOfCars.add(car3);
		listOfCars.add(car4);
		listOfCars.add(car5);// duplicate of car3
		listOfCars.add(null);

		// for each loop to iterate

		for (Car aCar1 : listOfCars)

		{

			// Print the VinNumber, Make, Model of the Cars
			System.out
					.println("VinNumber of the car : " + aCar1.getVinNumber());
			System.out.println("Make of the car :  " + aCar1.getMake());
			System.out.println("Model of the Car :" + aCar1.getModel());
			System.out.println("***************************");

		}

	}

}
